<!--
    page description : 근태관리 - 입력자 - 근태등록 화면 - 휴가입력 (pop_up)
    author      : Yang D
    date        : 2009-01-20
    file name   : vacation_open_p.jsp
-->
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<%@page import="attend.com.CodeMetrix"%><html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- <base target="_self" />[출처] ModalDialog에서 Form전송시(submit) 새창 안뜨게 하는 방법| -->
<s:head theme="ajax" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta http-equiv="pragma" 			content="no-cache" />
<meta http-equiv="cache-control" 	content="no-cache" />
<meta http-equiv="expires" 			content="0" />

<link rel="stylesheet" type="text/css" href="/inc/css/common.css" />
<link rel="stylesheet" type="text/css" href="style/style.css" />
<script src="inc/js/common.js"></script>
<title>휴가정보 입력</title>
	<!-- --------------------J A V A S C R I P T-START-------------------- -->
	<script type="text/javascript">
		/**
		onload시에 값을 전달함.
		opener의 js변수에 접근하여 hidden-yyyymmdd변수에 data를 전달함.
		*/
		function fnc_send_yyyymmdd() {
		
			//var args 								= window.dialogArguments;		//123,1234,1232,12321

			//opener에서 전달받은 parameter들 중에 체크된 기준을들을 뽑는다.

			//전달받은 정보를 다시 풀어서 hidden에 저장함.			
			//document.getElementById("emp_no").value 	= args.document.getElementById("emp_no").value;
			//document.getElementById("ip").value 		= '<%= request.getRemoteAddr() %>';
			
			var rtn_msg 								= document.getElementById("msg").value;	//저장되었는지 알려줌.
	        
	        if(rtn_msg != "<%= CodeMetrix.OK %>") {
	            alert(rtn_msg);
	            window.close();
	            opener.call_dojo();	//	부모창의 js function call... window.open와  다름.
	        }

		}
		
		//저장버튼 클릭
		function fnc_submit(f) {

			var sel_id = document.getElementById("vacation_type");
			var sel_val = sel_id.options[sel_id.selectedIndex].value; //select tag에서 선택된 value.
			var etc_emp = f.etc_emp.value.length;
			var temp = f.etc_emp.value;
			var i = 0;		//반복문 초기값
			var cnt = 0;	//공백 갯수

			if ((sel_val == 2001 || sel_val == 2002 || sel_val == 2003 || sel_val == 2004 || sel_val == 2005) && etc_emp==0){
				alert("<s:text name="alert.message.emptyEtc"/>");
				f.etc_emp.focus();
				return false;
			}else{
				//alert(temp);
				for(i=0;etc_emp > i;i++){
					if(temp.charAt(i) == " "){
						cnt++;	//공백갯수카운트
					}
				}
			}

			//공백이 넘어온 값이 길이와 같다면 공백이다.
			if(etc_emp == cnt){
				alert("공백값 입력은 받지 않습니다.");
				f.etc_emp.focus();
				return false;
			}
			   if(sel_val == 2001 || sel_val == 2002 || sel_val == 2003 || sel_val == 2004 || sel_val == 2005){
				  if (confirm("<s:text name="alert.message.questionSave" />")) {
					f.action = "attend_vacation_save_p2.action";
					f.submit();
					return false;
				  }
			   }	
			if (!confirm("<s:text name="alert.message.questionSave" />")) {
				return false;
			}
			f.action = "attend_vacation_save_p.action";	//저장 action
			f.submit();
			return false;
		}
		
		//휴가입력 저장시
		// ajax를 적용하여 opener의 죄회 데이터를 바로 적용함.
	    function fnc_apply_change() {
	        
	    }

	</script>
	<!-- --------------------J A V A S C R I P T-E N D-------------------- -->
</head>
<body onload="fnc_send_yyyymmdd()">
        <s:form name="frm" id="frm" method="post" theme="simple" >
        <s:hidden name="vaca_in_out_tp" id="vaca_in_out_tp" value="%{vaca_in_out_tp}"	/> <!--1/19  -->
        <s:hidden name="yyyymmdd" id="yyyymmdd" value="%{vaca_yyyymmdd}"	/>
        <s:hidden name="emp_no"   id="emp_no"	/>
        <input type="hidden" name="ip" 	  id="ip"	value="<%=request.getRemoteAddr() %>"	/>
        <s:hidden name="msg" 	  id="msg"		/>
        <s:hidden name="chk_in_msg" id="chk_in_msg" />
        
        <div id="popup_350se_top"></div>
        <div id="popup_350se_bg">
	    	<div id="popup_325se">
	    		<div id="popup_325se_box">
	    			<ul>
	    				<li class="txt">휴가유형</li>
	    				<li><s:select name="vacation_type" id="vacation_type" cssClass="combobox120se" list="listCommonCode" listKey="cd" listValue="cd_nm" /></li>
	    			</ul>
	    			<ul>
	    				<li class="txt">비고</li>
	    				<li><s:textfield cssClass="input_120se" maxlength="16" name="etc_emp" value="%{msg_etc_emp}" /></li>
	    			</ul>
	    		</div>
	    		<div id="popup_btn"><input type="image" src="/images/btn_save.gif" value="저장" onclick="return fnc_submit(this.form)" /></div>
	    	</div>
	    </div>
	    <!---------------Bottom : STR----------->
		<div id="popup_350se_bottom"><s:submit type="image" src="/images/pop_btn_close.gif" onclick="window.close(); return false;"/></div>
		<!---------------Bottom : END----------->
	</s:form>
</body>
</html>